﻿#region AmortizationSchedule
//
// All rights are reserved. Reproduction or transmission in whole or in part, in 
// any form or by any means, electronic, mechanical or otherwise, is prohibited 
// without the prior written consent of the copyright owner.
// 
// Filename: AmortizationSchedule.cs
//
#endregion 
using System;

using System.Collections.Generic;
using System.Runtime.Serialization;

namespace DiscoveryLogic.DataServices.DataObjects
{
    /// <summary>
    /// Entity Class representing an Amortization schedule
    /// </summary>
    [DataContract] 
    public class AmortizationSchedule
    {
        /// <summary>
        /// holder for schedule ID
        /// </summary>
        private string scheduleId;

        /// <summary>
        /// holder for principalBorrowed
        /// </summary>
        private double principalBorrowed;

        /// <summary>
        /// holder for term in years
        /// </summary>
        private int termInYears;

        /// <summary>
        /// holder for total payments scheduled 
        /// </summary>
        private int totalPayments;

        /// <summary>
        /// holder for annual Interest Rate
        /// </summary>
        private double annualInterestRate;

        /// <summary>
        /// holder for per payment interest rate
        /// </summary>
        private double periodicInterestRate;

        /// <summary>
        /// holder for regular payment amount
        /// </summary>
        private double regularPaymentAmount;

        /// <summary>
        /// holder for end of term balloon payment
        /// </summary>
        private double finalBalloonPayment;

        /// <summary>
        /// holder for total repaid
        /// </summary>
        private double totalRepaid;

        /// <summary>
        /// holder for total interest as a percent of principal
        /// </summary>
        private double totalInterestAsPercentOfPrincipal;

        /// <summary>
        /// holder fot start of term date
        /// </summary>
        private DateTime startDate;

        /// <summary>
        /// holder for payment plan
        /// </summary>
        private List<ScheduleEntry> paymentPlan;

        /// <summary>
        /// getter/setter for schedule id
        /// </summary>
        [DataMember] 
        public string ScheduleId
        {
            get { return scheduleId; }
            set { scheduleId = value; }
        }

        /// <summary>
        /// getter/setter for principal borrowed
        /// </summary>
        [DataMember] 
        public double PrincipalBorrowed
        {
            get { return principalBorrowed; }
            set { principalBorrowed = value; }
        }

        /// <summary>
        /// getter/setter for term in years
        /// </summary>
        [DataMember] 
        public int TermInYears
        {
            get { return termInYears; }
            set { termInYears = value; }
        }

        /// <summary>
        /// getter/setter for total payments
        /// </summary>
        [DataMember]
        public int TotalPayments
        {
            get { return totalPayments; }
            set { totalPayments = value; }
        }

        /// <summary>
        /// getter/setter for annual interest rate
        /// </summary>
        [DataMember]
        public double AnnualInterestRate
        {
            get { return annualInterestRate; }
            set { annualInterestRate = value; }
        }

        /// <summary>
        /// getter/setter for periodic interest rate
        /// </summary>
        [DataMember]
        public double PeriodicInterestRate
        {
            get { return periodicInterestRate; }
            set { periodicInterestRate = value; }
        }

        /// <summary>
        /// getter/setter for regular payment amount
        /// </summary>
        [DataMember]
        public double RegularPaymentAmount
        {
            get { return regularPaymentAmount; }
            set { regularPaymentAmount = value; }
        }

        /// <summary>
        /// getter/setter for final balloon payment
        /// </summary>
        [DataMember] 
        public double FinalBalloonPayment
        {
            get { return finalBalloonPayment; }
            set { finalBalloonPayment = value; }
        }

        /// <summary>
        /// getter/Setter for total repaid
        /// </summary>
        [DataMember]
        public double TotalRepaid
        {
            get { return totalRepaid; }
            set { totalRepaid = value; }
        }

        /// <summary>
        /// getter/setter for total interest as a percent of principal
        /// </summary>
        [DataMember] 
        public double TotalInterestAsPercentOfPrincipal
        {
            get { return totalInterestAsPercentOfPrincipal; }
            set { totalInterestAsPercentOfPrincipal = value; }
        }


        /// <summary>
        /// getter/setter for term start date
        /// </summary>
        [DataMember]
        public DateTime StartDate
        {
            get { return startDate; }
            set { startDate = value; }
        }

        /// <summary>
        /// Indexer for payment schedule entries
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>Schedule entrye</returns>
        // [DataMember] 
        public ScheduleEntry this[int index]
        {
            get
            {
                //Check the index limits.
                if (index < 0 || index >= paymentPlan.Count)
                {
                    return null;
                }
                else
                {
                    return paymentPlan[index];
                }
            }
            set
            {
                if (!(index < 0 || index >= paymentPlan.Count))
                {
                    paymentPlan[index] = value;
                }
            }
        }


    }
}
